<?php
/* @var $this yii\web\View */
$this->title = 'QA问答系统';
?>
<div class="site-index">
    <div class="body-content">
        <div class="row">
            <div class="col-lg-12">

                <!--问答-->
                <table class="table">
                    <h3>问答<small class="pull-right"><a href="<?php echo Yii::$app->urlManager->createUrl(['qa']); ?>" class="btn btn-link">更多</a></small></h3>
                    <tbody>
                        <?php foreach ($qa_list as $row): ?>
                            <tr>
                                <td class="w50"><div class="<?php echo $row->comments ? 'answers' : 'no-answers' ?>"><?php echo $row->comments; ?><small>回答</small></div></td>
                                <td class="w50"><div class="views"><?php echo $row['view']; ?><small>浏览</small></div></td>
                                <td>
                                    <span><?php echo $row->author->username ?> &nbsp;&nbsp;<?php echo Yii::$app->formatter->asRelativeTime($row->created_at) ?>&nbsp;发布</span><br>
                                    <a href="<?php echo Yii::$app->urlManager->createUrl(['qa/view', 'id' => $row['id']]); ?>"><?php echo $row['title']; ?></a>
                                    <?php foreach ($row->tags($row['id']) as $item): ?>
                                        <a class="btn btn-success btn-xs" href="<?php echo Yii::$app->urlManager->createUrl(['tags/show', 'id' => $item->id]); ?>" role="button"><?php echo $item->name ?></a>
                                    <?php endforeach; ?>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>

                <!--文章-->
                <table class="table">
                    <h3>文章<small class="pull-right"><a href="<?php echo Yii::$app->urlManager->createUrl(['article']); ?>" class="btn btn-link">更多</a></small></h3>
                    <tbody>
                        <?php foreach ($article_list as $row): ?>
                            <tr>
                                <td class="w50"><div class="<?php echo $row->recommend ? 'answers' : 'no-answers' ?>"><?php echo $row->recommend; ?><small>点赞</small></div></td>
                                <td class="w50"><div class="views"><?php echo $row['view']; ?><small>浏览</small></div></td>
                                <td>
                                    <span><?php echo $row->author->username ?> &nbsp;&nbsp;<?php echo Yii::$app->formatter->asRelativeTime($row->created_at) ?>&nbsp;发布</span><br>
                                    <a href="<?php echo Yii::$app->urlManager->createUrl(['article/view', 'id' => $row['id']]); ?>"><?php echo $row['title']; ?></a>
                                    <?php foreach ($row->tags($row['id']) as $item): ?>
                                        <a class="btn btn-success btn-xs" href="<?php echo Yii::$app->urlManager->createUrl(['tags/show', 'id' => $item->id]); ?>" role="button"><?php echo $item->name ?></a>
                                    <?php endforeach; ?>
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>

            </div>
        </div>
    </div>
</div>